package com.sgb.kjwl.api.net;

import com.sgb.kjwl.BuildConfig;
import com.sgb.kjwl.api.service.NewUploadAPI;
import com.sgb.kjwl.api.service.UploadAPI;
import com.sgb.net.core.BaseCompatibleNet;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

/**
 * @author: 杨畔
 * @date: 2021/7/6 09:36
 * @Description: 上传文件网络请求类
 */
public class UploadNet extends BaseCompatibleNet {

    private final UploadAPI mService;
    private final NewUploadAPI mNewUploadService;

    private UploadNet() {
        mService = getService(UploadAPI.class, mBaseUrl);
        mNewUploadService = getService(NewUploadAPI.class, BuildConfig.BASE_URL_SP);
    }

    private static class Single {
        private static final UploadNet instance = new UploadNet();
    }

    public static UploadNet getInstance() {
        return Single.instance;
    }

    @Override
    protected void handleBuilder(OkHttpClient.Builder builder) {
        builder.connectTimeout(150, TimeUnit.SECONDS)
                .readTimeout(150, TimeUnit.SECONDS)
                .writeTimeout(150, TimeUnit.SECONDS);
    }

    public UploadAPI getService() {
        return mService;
    }

    public NewUploadAPI getNewUploadService() {
        return mNewUploadService;
    }
}
